/**
 * Created by hjx on 2019/3/4.
 */
(function () {
    var exports = this;
    var $;
    var YureLayer = cc.Layer.extend({
        ctor: function () {
            this._super();
            var that = this;
            loadNodeCCS(res.znq_YureLayer, this);
            $ = create$(this.getChildByName("Layer"));
            var curIndex = 1;
            var moveEventFunc = function () {
                if (curIndex == 1) {
                    $('yure1').setVisible(true);
                    $('yure2').setVisible(false);
                    $('yure3').setVisible(false);
                    $('btn_left').setVisible(false);
                    $('btn_right').setVisible(true);
                } else if (curIndex == 2) {
                    $('yure1').setVisible(false);
                    $('yure2').setVisible(true);
                    $('yure3').setVisible(false);
                    $('btn_left').setVisible(true);
                    $('btn_right').setVisible(true);
                } else if (curIndex == 3) {
                    $('yure1').setVisible(false);
                    $('yure2').setVisible(false);
                    $('yure3').setVisible(true);
                    $('btn_left').setVisible(true);
                    $('btn_right').setVisible(false);
                }
            }
            moveEventFunc();
            TouchUtil.setOnclickListener($('btn_right'), function () {
                curIndex++;
                moveEventFunc();
            });
            TouchUtil.setOnclickListener($('btn_left'), function () {
                curIndex--;
                moveEventFunc();
            });
            TouchUtil.setOnclickListener($('root'), function () {
                that.removeFromParent();
            });
            TouchUtil.setOnclickListener($('btn_close'), function () {
                that.removeFromParent();
            });

            $('btn_share').runAction(cc.repeatForever(cc.sequence(cc.rotateBy(1,10),cc.rotateBy(1,-10))))
            TouchUtil.setOnclickListener($('btn_share'), function () {
                that.addChild(new ShareLayer_znq());
            });
        }

    });
    exports.YureLayer = YureLayer;
})(window);